<?php

namespace App\Transformers;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
use League\Fractal\TransformerAbstract;

class MediaTransformer extends TransformerAbstract
{

    protected $hidden = ['path'];

    public function transform(Model $model)
    {
        $model->makeHidden($this->hidden);
        return $model->attributesToArray() + [
                'path' => \Storage::url($model->path),
                'disk' => $model->path
            ];
    }
}